package com.example.caorl.job1to4.gateway.router;

import java.util.List;
import java.util.Random;

public class RandomHttpEndpointRouter implements HttpEndpointRouter {

    public static HttpEndpointRouter randomHttpEndpointRouter = new RandomHttpEndpointRouter();

    private RandomHttpEndpointRouter(){}

    public static HttpEndpointRouter getInstance(){
        return randomHttpEndpointRouter;
    }

    @Override
    public String route(List<String> urls) {
        int size = urls.size();
        Random random = new Random(System.currentTimeMillis());
        return urls.get(random.nextInt(size));
    }

    @Override
    public void routeFinish(String url) {

    }

}
